package cn.bluemobi.platform.utils;

import javax.servlet.http.HttpServletRequest;

import com.alipay.api.AlipayApiException;

public class RefundUtils {
    /**
     * 支付宝退款 Description: <br/>
     * 
     * @author lvxh
     * @param batchNo 支付号
     * @param tradeNo 支付交易号
     * @param refundAmount 退款金额
     * @param outRequestNo 分布退款单号
     * @return
     * @throws AlipayApiException
     */
    public static boolean alipayRefund(String batchNo, String tradeNo, String refundAmount, String outRequestNo)
            throws AlipayApiException {
        // refundAmount = "0.01";
        // AlipayClient alipayClient = new
        // DefaultAlipayClient(PropertiesUtils.getProperty("ALI_REFUNND_URL"),
        // PropertiesUtils.getProperty("ALI_APP_ID"),
        // PropertiesUtils.getProperty("ALI_PRIVATE_KEY"), "json",
        // "GBK", PropertiesUtils.getProperty("ALI_PUBLIC_KEY"));
        // AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
        // request.setBizContent("{" + "\"out_trade_no\":\"" + batchNo + "\"," +
        // "\"trade_no\":\"" + tradeNo + "\","
        // + "\"refund_amount\":" + refundAmount + "," + "\"out_request_no\":\""
        // + outRequestNo + "\"}");
        // AlipayTradeRefundResponse response = alipayClient.execute(request);
        // System.out.println(response.getBody());
        // if (response.isSuccess()) {
        // System.out.println("调用成功");
        // return true;
        // } else {
        // System.out.println("调用失败");
        return false;
        // }
    }

    public static boolean wechatRefund(String batchNo, String transactionId, String totalFee, String refundFee,
            String outRefundNo, String type, HttpServletRequest request) {
        // Map<String, String> map = new HashMap<>();
        // if (StringUtils.equals(type, "APP")) {
        // map = WechatPayUtil.wechatRefund(batchNo, transactionId, totalFee,
        // refundFee, outRefundNo, request);
        // }
        // if (StringUtils.equals(type, "WEB")) {
        // map = WechatPayUtilWeb.wechatRefund(batchNo, transactionId, totalFee,
        // refundFee, outRefundNo, request);
        // }
        // Map<String, String> map = WechatPayUtil.wechatRefund(batchNo,
        // transactionId, totalFee, refundFee, outRefundNo,
        // request);
        // System.out.println(map.toString());
        // if (StringUtils.equals(map.get("result_code"), "SUCCESS")) {
        // System.out.println("调用成功");
        // return true;
        // } else {
        // System.out.println("调用失败");
        return false;
        // }
    }

}
